import os
from datetime import timedelta

class Config:
    """基础配置"""
    SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key')
    DEBUG = True
    TESTING = False
    HOST = '0.0.0.0'
    PORT = 5000
    DATABASE_URI = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'ai_chat.db')
    
    # JWT配置
    JWT_EXPIRE_SEC = 3600 * 24  # 24小时
    
    # AI服务配置
    AI_TIMEOUT = 300  # 5分钟
    DEFAULT_AI_SERVER = os.getenv('DEFAULT_AI_SERVER', 'http://localhost:11434')
    DEFAULT_AI_MODEL = os.getenv('DEFAULT_AI_MODEL', 'deepseek-r1:32b')
    
    # 模板配置
    TEMPLATES_AUTO_RELOAD = True

class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    CORS_ORIGINS = '*'  # 开发环境允许所有跨域请求

class ProductionConfig(Config):
    """生产环境配置"""
    DEBUG = False
    CORS_ORIGINS = os.getenv('CORS_ORIGINS', 'https://your-domain.com')

class TestingConfig(Config):
    """测试环境配置"""
    TESTING = True
    DATABASE_URI = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'test_ai_chat.db')
